<?php
namespace app\common\validate\Product;

use think\Validate;

// 商品单位的验证器
class Product extends Validate
{
    protected $rule =   [
        'name'  => ['require','unique:product'],
        'content' => ['require'],
        'flag' => ['require','in:1,2,3'],
        'status' => ['require','in:0,1'],
        'stock' => ['require','number','>=:0'],
        'typeid' => ['require'],
        'unitid' => ['require'],
        'price' => ['require','number','>=:0']
    ];

    protected $message  =   [
        'name.require' => '商品名称必须填写',
        'name.unique' => '商品名称必须唯一',
        'content.require' => '商品描述必须填写',
        'flag.require' => '标签必须填写',
        'flag.in' => '标签值不在规定范围内',
        'status.require' => '状态必须填写',
        'status.in' => '状态值不在规定范围内',
        'stock.require' => '库存必须填写',
        'stock.number' => '库存必须是数字',
        'stock.>=' => '库存必须大于0',
        'typeid.require' => '商品分类必须填写',
        'unitid.require' => '商品单位必须填写',
        'price.require' => '价格必须填写',
        'price.number' => '价格必须是数字',
        'price.>=' => '价格必须大于0',
    ];
}
